package com.example.demo.app;

import com.example.demo.domain.app.param.ShoppingCartParam;
import com.example.demo.domain.app.param.ShoppingCartSelectParam;
import com.example.demo.domain.app.param.ShoppingCartUpdateNumParam;
import com.example.demo.domain.app.vo.ShoppingCartVO;
import com.example.demo.domain.base.BaseResult;
import com.example.demo.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ShoppingCartController
 *
 * @author haochen78
 * @date 2025/11/9 16:04
 **/
@RestController
@RequestMapping("/app/shopping-cart")
public class ShoppingCartController {

    @Autowired
    private ShoppingCartService shoppingCartService;

    @GetMapping("/info")
    private BaseResult<ShoppingCartVO> info() {
        return BaseResult.success(shoppingCartService.info());
    }

    @PostMapping("/select")
    private BaseResult<ShoppingCartVO> select(@RequestBody ShoppingCartSelectParam select) {
        return BaseResult.success(shoppingCartService.select(select));
    }

    @PostMapping("/add")
    private BaseResult<ShoppingCartVO> add(@RequestBody ShoppingCartParam param) {
        return BaseResult.success(shoppingCartService.add(param));
    }

    @PostMapping("/modifyNumber")
    private BaseResult<ShoppingCartVO> modifyNumber(@RequestBody ShoppingCartUpdateNumParam param) {
        return BaseResult.success(shoppingCartService.modifyNumber(param));
    }

    @PostMapping("/remove")
    private BaseResult<ShoppingCartVO> remove() {
        return BaseResult.success(new ShoppingCartVO());
    }
}
